#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(addItem()));
    //ui->listView
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::addItem()
{
    ListViewDelegate* listDelegate;
    listDelegate = new ListViewDelegate();

    QStandardItemModel* model;
    model = new QStandardItemModel();

    ui->listView->setItemDelegate(listDelegate);
    ui->listView->setModel(model);

    for (int i = 0; i < 12; i++)
    {
        addRowtoListView(i, model);
    }


    qDebug() << "blabla" << model->rowCount();

}

void MainWindow::addRowtoListView(int row, QStandardItemModel *model)
{
    QStandardItem* item = new QStandardItem();
    item->setData(QString::number(row), ListViewDelegate::HeaderRole);
    item->setData("blahblahblah, you may see event desc. in here!", ListViewDelegate::SubheaderRole);

    model->appendRow(item);
}
